using JGSY.CMS.LowCode.Platform.Application.Interfaces;
using JGSY.CMS.LowCode.Platform.Application.DTOs;
using System.Collections.Generic;
using System.Threading.Tasks;
using System;
using System.Diagnostics;

namespace JGSY.CMS.LowCode.Platform.Application.Services
{
    /// <summary>
    /// 用户设备应用服务
    /// 提供用户设备的增删改查等设备管理相关业务功能
    /// </summary>
    [JGSY.CMS.LowCode.Platform.Infrastructure.Services.LogOperation]
    public class UserDeviceAppService : IUserDeviceAppService
    {
        /// <summary>
        /// 用户设备服务接口
        /// </summary>
        private readonly IUserDeviceService _service;

        /// <summary>
        /// 构造函数，注入用户设备服务
        /// </summary>
        /// <param name="service">用户设备服务接口</param>
        public UserDeviceAppService(IUserDeviceService service)
        {
            _service = service;
        }
        
        /// <summary>
        /// 获取所有用户设备
        /// </summary>
        /// <returns>用户设备列表</returns>
        public async Task<IEnumerable<UserDeviceDto>> GetAllAsync()
        {
            return await _service.GetAllAsync();
        }
        
        /// <summary>
        /// 根据ID获取用户设备
        /// </summary>
        /// <param name="id">设备标识符</param>
        /// <returns>用户设备信息</returns>
        public async Task<UserDeviceDto?> GetByIdAsync(long id)
        {
            return await _service.GetByIdAsync(id);
        }
        
        /// <summary>
        /// 添加新的用户设备
        /// </summary>
        /// <param name="entity">用户设备数据传输对象</param>
        /// <returns>添加任务</returns>
        public async Task AddAsync(UserDeviceDto entity)
        {
            await _service.AddAsync(entity);
        }
        
        /// <summary>
        /// 更新用户设备信息
        /// </summary>
        /// <param name="id">设备标识符</param>
        /// <param name="entity">用户设备数据传输对象</param>
        /// <returns>更新任务</returns>
        public async Task UpdateAsync(long id, UserDeviceDto entity)
        {
            await _service.UpdateAsync(id, entity);
        }
        
        /// <summary>
        /// 删除用户设备
        /// </summary>
        /// <param name="id">设备标识符</param>
        /// <returns>删除任务</returns>
        public async Task DeleteAsync(long id)
        {
            await _service.DeleteAsync(id);
        }
    }
}
